<?php
require('simplecomet.class.php');
$comet = new SimpleComet();
 
$mid = intval($_GET['mid']);

function curPageURL() {
	$host  = $_SERVER['HTTP_HOST'];
	$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
	return $host.$uri;
}

$hostURL = "http://".curPageURL()."/cricket/crontab/commet_update/?mid=$mid";
 
// This is an infinite loop, which makes the stream endless.
while (true) {
	$content = file_get_contents($hostURL);
	//$excuse .= "~!@#$%^&*()_+`'/.,<>:|\+=";
	$comet->push($content);
	// 5 seconds delay before the next excuse.
	sleep(25);
}